
*** Creates estimates for Table A1 and Figures 2 from the 1972-76 panel data

*** Creation of 56/60, 72/76, 92/96, and 00/04 data files documented in dataverse for 2017 AJPS - Polarization and the Decline of the American Floating Voter - dataverse link: https://doi.org/10.7910/DVN/4FCVUR


clear
use "data/amelia70s.dta" 
merge 1:1 id using "data/observed70s.dta"
drop _merge
merge 1:1 id using "data/id_panel1972.dta"
drop _merge

svyset PSU

** PID matches
svy: proportion pid72
svy: proportion pid76

tab pid72 
tab pid76

gen partyidswitch = 0 if pid72!=. & pid76!=.
replace partyidswitch = 1 if pid72<=2 & pid76>=4 & pid76<7
replace partyidswitch = 1 if pid72>=4 & pid72<7 & pid76<=2
svy: proportion partyidswitch

tab partyidswitch latentstrong_nodif, col
tab partyidswitch latentstrong_dif, col

drop partyidswitch

svy: proportion pref72
svy: proportion pref76

** note 72/76 didn't ask non-voters preference
tab pref72 votedin72
tab pref76 votedin76


gen prefswitch = 0 if pref72!=. & pref76!=.
replace prefswitch = 1 if pref72==1 & pref76==2
replace prefswitch = 1 if pref72==2 & pref76==1
svy: proportion prefswitch 
drop prefswitch


mi set mlong

misstable summarize

mi register imputed age education female black catholic income72 cooperate72 polsoph72 intel72 suspicious72 interest72 sincerity72 pid72 blackstherm*72 souththerm*72 demtherm72 reptherm72 demcandtherm_pre72 repcandtherm_pre72 repcandtherm76 demcandtherm76 pid74 pardon74 pid76 presapprove72 presapprove74 presapprove76 prepref72 prepref76 pref72 pref76
 
mi impute chained (truncreg, ll(17) ul(95) omit(i.pid72 cooperate72 intel72 suspicious72 interest72 i.catholic sincerity72 i.pid76 i.prepref76 i.prepref72 i.pid74 income72  blackstherm72 souththerm72 demtherm72 reptherm72 i.pardon74 i.presapprove76 i.presapprove74 i.presapprove72 demcandtherm_pre72 repcandtherm_pre72 repcandtherm76 demcandtherm76 i.pref72 i.pref76)) age (logit, omit(i.pid76 i.prepref76 i.pid74 i.presapprove74 i.presapprove76 i.pardon74 i.prepref72 blackstherm72 souththerm72  demtherm72 reptherm72  demcandtherm_pre72 repcandtherm_pre72 repcandtherm76 demcandtherm76 i.pref72 i.pref76) ) catholic  presapprove72 (ologit, ascontinuous omit( i.pid72  i.pid76 i.prepref76 i.prepref72 i.pid74 blackstherm72 souththerm72  demtherm72 reptherm72 i.pardon74 i.presapprove76 i.presapprove74 i.presapprove72  demcandtherm_pre72 repcandtherm_pre72 repcandtherm76 demcandtherm76 i.pref72 i.pref76) ) income72 cooperate72 polsoph72 intel72 suspicious72 interest72 sincerity72  (ologit, omit(polsoph72 sincerity72 i.pid76 i.prepref76 i.prepref72 i.pid74 income72 blackstherm72 souththerm72 i.pardon74 i.presapprove76 i.presapprove74 i.presapprove72 repcandtherm76 demcandtherm76 i.pref72 i.pref76)) pid72 (truncreg, ll(0) ul(97) omit(i.pid76 i.prepref76 i.pardon74 i.pid74 i.presapprove76 i.presapprove74 repcandtherm76 demcandtherm76 i.pref72 i.pref76)) demcandtherm_pre72 repcandtherm_pre72 blackstherm72 souththerm72 demtherm72 reptherm72 (mlogit, augment omit(i.prepref76 i.pardon74 i.pid74 i.presapprove76 i.presapprove74 repcandtherm76 demcandtherm76 i.pref76 i.pid76  cooperate72 intel72 suspicious72 interest72 sincerity72 demtherm72 reptherm72  income72 i.catholic i.pref72)) prepref72  (mlogit, augment omit(i.prepref76 i.pardon74 i.pid74 i.presapprove76 i.presapprove74 repcandtherm76 demcandtherm76 i.pref76 i.pid76  cooperate72 intel72 suspicious72 interest72 sincerity72 demtherm72 reptherm72 income72 i.catholic)) pref72  (ologit, omit( i.pid76 i.prepref76 i.presapprove76)) pid74 (logit, omit( i.pid76 i.prepref76 i.presapprove76 repcandtherm76 demcandtherm76 i.pref76  demcandtherm_pre72 repcandtherm_pre72  demtherm72 reptherm72)) presapprove74 pardon74  (ologit, omit(i.prepref72 i.prepref76 i.pref76 repcandtherm76 demcandtherm76  demcandtherm_pre72 repcandtherm_pre72  demtherm72 reptherm72 i.presapprove72 i.presapprove74 i.pid72)) pid76 (logit, omit(i.prepref72 i.pid72 i.pid74 i.prepref76 i.pref76 demcandtherm_pre72 repcandtherm_pre72  demtherm72 reptherm72)) presapprove76 (truncreg, ll(0) ul(97) omit(i.pid72 i.pid74 i.pref72 i.prepref72  demcandtherm_pre72 repcandtherm_pre72  demtherm72 reptherm72)) repcandtherm76 demcandtherm76 (mlogit, augment omit(i.pref72 i.prepref72 i.pid72 i.pid74 demcandtherm_pre72 repcandtherm_pre72 demtherm72 reptherm72 i.presapprove74 i.presapprove72 i.pref76  cooperate72 intel72 suspicious72 interest72 sincerity72)) prepref76  (mlogit, augment omit(i.prepref72 i.pid72 i.pid74 demcandtherm_pre72 repcandtherm_pre72 demtherm72 reptherm72 i.presapprove74 i.presapprove72 i.prepref76 midwest cooperate72 intel72 suspicious72 interest72 sincerity72)) pref76 = education female south midwest black, add(40) burnin(20) chaindots rseed(332211)


mi estimate: svy: proportion pid72
mi estimate: svy: proportion pid76

mi passive: gen partyidswitch = 0 
mi passive: replace partyidswitch = 1 if pid72<=2 & pid76>=4 & pid76<7
mi passive: replace partyidswitch = 1 if pid72>=4 & pid72<7 & pid76<=2

mi estimate: proportion partyidswitch


mi estimate, saving(mi_mlogit72, replace): mlogit pref72 i.pid72 repcandtherm_pre72 demcandtherm_pre72 age female black catholic south, base(1) 
mi predict xb72_1_mi using mi_mlogit72
mi predict xb72_2_mi using mi_mlogit72, equation(#2)
mi predict xb72_3_mi using mi_mlogit72, equation(#3)
mi xeq 0: summarize xb72_1_mi xb72_2_mi xb72_3_mi

mi passive: gen demvrepphat72 = 1/(1+exp(xb72_2_mi))
mi estimate: mean demvrepphat72
mi passive: gen simdem72 = uniform()<=demvrepphat72
mi passive: gen demvrepchoice72 = 0 if pref72<=2
mi passive: replace demvrepchoice72 = 1 if pref72==1
mi passive: replace demvrepchoice72 = simdem72 if demvrepchoice72==.

mi estimate: svy: proportion pref72 demvrepchoice72

mi estimate, saving(mi_mlogit76, replace): mlogit pref76 i.pid76 repcandtherm76 demcandtherm76 age female black catholic south, base(1) 

mi predict xb76_1_mi using mi_mlogit76
mi predict xb76_2_mi using mi_mlogit76, equation(#2)
mi predict xb76_3_mi using mi_mlogit76, equation(#3)
mi xeq 0: summarize xb76_1_mi xb76_2_mi xb76_3_mi

mi passive: gen demvrepphat76 = 1/(1+exp(xb76_2_mi))
mi estimate: mean demvrepphat76
mi passive: gen simdem76 = uniform()<=demvrepphat76
mi passive: gen demvrepchoice76 = 0 if pref76<=2
mi passive: replace demvrepchoice76 = 1 if pref76==1
mi passive: replace demvrepchoice76 = simdem76 if demvrepchoice76==.

mi estimate: svy: proportion pref76 demvrepchoice76

mi passive: gen supportswitch = 0 
mi passive: replace supportswitch = 1 if pref72==1 & pref76==2
mi passive: replace supportswitch = 1 if pref72==2 & pref76==1

mi estimate: svy: proportion supportswitch

drop supportswitch

****************
** no 3rd party
****************

** make sure imputed values are consistent

mi passive: gen supportswitch = 0 
mi passive: replace supportswitch = 1 if demvrepchoice72!=demvrepchoice76
mi estimate: svy: proportion supportswitch 









